Repository navigation
[SVLS-10133] Warn when instrumenting Lambda functions below 256 MB - #775
avangelillo wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
git-thuerk-done
left a comment
There was a problem hiding this comment.
Thanks for adding this! The wording matches the other SVLS-10133 PRs well: same threshold, reason code, and warn-only behavior. A few optional suggestions are inline.
- Across the five SVLS-10133 PRs, the four tools say "about 69 MB for Python" and the docs PR says "about 70 MB". Could you align them? Also, is the figure stable enough to hard-code in the warning text, or might it change between tracer releases?
Co-authored-by: Alicia Thuerk <alicia.thuerk@datadoghq.com>
@git-thuerk-done I'll align them to 70MB for now, and double check if that is stable enough to keep the number at all. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks! I aligned the figure on about 70 MB in all five PRs (afa596e here). It's a rounded, approximate number in the warning, and the docs have the details, so it won't need to change with every tracer release. |
ava-silver
left a comment
There was a problem hiding this comment.
Automated AI Review (human curated)
Threshold, provider.memorySize inheritance, Serverless 1024 MB default handling, and logToCliOnce integration look good. One inline issue where functions that receive no Datadog layers still trigger the warning.
| if (config.suppressLowMemoryWarning !== true) { | ||
| for (const warning of getLowMemoryWarnings(this.serverless.service, handlers)) { | ||
| this.logToCliOnce(`Warning: ${warning}`); | ||
| } | ||
| } |
There was a problem hiding this comment.
This runs before checking config.addLayers / config.addExtension, and getLowMemoryWarnings only skips RuntimeType.UNSUPPORTED. As a result, functions that get no Datadog layers still warn -- for example:
- A 128 MB Python function with
addLayers: falseandaddExtension: falsereceives no layers but still prints a warning blaming extension and tracer layer overhead. - A 128 MB
.NETorJavafunction withaddExtension: falsereceives no layers (sinceapplyLambdaLibraryLayersskips those runtimes without the extension) but still warns.
This also differs from the PR description ("those the plugin doesn't add layers to, are skipped"). Consider gating on config.addLayers || config.addExtension and skipping extension-only runtimes when !config.addExtension (or updating the PR description if warning unconditionally is intended).
What does this PR do?
The plugin now prints a warning for each instrumented function with less than 256 MB of memory. It still instruments those functions exactly as before. Set
custom.datadog.suppressLowMemoryWarning: trueto silence it.Effective memory is
functions.<fn>.memorySize??provider.memorySize?? 1024 (the Serverless Framework default). Values that aren't plain numbers, such as unresolved variables, are not flagged. Excluded functions, and those the plugin doesn't add layers to, are skipped. The warning goes through the existinglogToCliOncewith the plugin's usualWarning:prefix.Motivation
The Datadog Lambda Extension and tracer layers run inside the function and add memory overhead, about 70 MB with the Python tracer. On functions with 128 MB of memory and short timeouts, that overhead can cause out-of-memory errors and timeouts once the function is instrumented. Datadog's automatic setup now skips first-time installs on functions below 256 MB, recording the reason
lambda_low_memory. This PR adds a matching safeguard here, with the same threshold and reason code, as part of SVLS-10133.Companion PRs make the same change in datadog-ci, serverless-plugin-datadog, datadog-cdk-constructs, datadog-cloudformation-macro, terraform-aws-lambda-datadog and the public docs.
Testing Guidelines
A new
low-memory warningsuite runs the realbefore:package:createDeploymentArtifactshook. It covers:enabled: falseprints nothingyarn test(278),yarn lint,yarn check-formattingandyarn buildpass.Additional Notes
Warn-only, so this is not a breaking change. An opt-in skip mode was left out of scope.
Types of changes
Check all that apply
🤖 Generated with Claude Code